<template>
  <div>
          <el-dialog
            title="工单配置"
            :visible="centerDialog"
            width="40%"
            font-weight='700'
          :before-close='Dialog'
            >
            <!-- 补货警戒线 -->
            <div class="Warning ">
                <span>补货警戒线 :</span>
                  <el-input-number v-model="alertValue"
                  controls-position="right"
                  :min="1" :max="100"></el-input-number>
            </div>
            <span slot="footer" class="dialog-footer">
              <el-button @click="Dialog">取 消</el-button>
              <el-button type="primary" @click="Automatic">确 定</el-button>
            </span>
          </el-dialog>
  </div>
</template>

<script>
import { EarlyWarning, Automatic } from '@/api/management'
export default {
  name: 'DikticDkdConfiguration',
  props: {
    centerDialog: {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {
      alertValue: 0
    }
  },

  mounted () {
    this.EarlyWarning()
  },

  methods: {
    Dialog () {
      this.$emit('update:centerDialog', false)
    },
    // 获取补货预警值
    async EarlyWarning () {
      try {
        const res = await EarlyWarning()
        console.log(res)
        this.alertValue = res
      } catch (e) {
        console.log(e)
      }
    },
    // 设置自动补货工单阈值
    async Automatic () {
      try {
        await Automatic({
          alertValue: this.alertValue
        })
        this.Dialog()
      } catch (e) {
        console.log(e)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog__title {
  font-weight: 700;
}
::v-deep .el-dialog__header {
   height: 52px;
   box-sizing: border-box;
   display: flex;
}
::v-deep .el-dialog__footer{
    text-align: center;
 }
  ::v-deep .el-button{
       margin-right: 20px;
       background-color: #fbf4f0;
       border: solid 0px #fff;
       color: #000;
       &:hover{
         background-color: #ff6e2a;
       }
    }
.Warning{
  span{
     margin-left:30px ;
     width: 140px;
  }
  ::v-deep .el-input-number{
    margin-left:20px;
    width: 390px;
  }
}
::v-deep .el-dialog{
   border-radius:20px;
}
</style>
